package pl.smath.regex.tree;

import pl.smath.regex.tree.vertexes.Vertex;

public class Token {

	/**
	 * Token is a basic element of tape.
	 * It can be either string (part of given expression) or already matched vertex.
	 */
	
	private String str;
	private Vertex ver;
	
	public Token(String str) {
		this.str = str;
	}
	
	public Token(Vertex ver) { 
		this.setVertex(ver);
	}
	
	public Boolean isString() {
		return (str != null);
	}

	private void setVertex(Vertex ver) {
		this.ver = ver;
	}

	public Vertex getVertex() {
		return ver;
	}
	
	public String toString() {
		if (isString())
			return str;
		return ver.serialize();
	}
	
}
